Skip to content

Add filter flags to branch list-tablets#1272

Merged
nickvanw merged 1 commit into
mainfrom
add-list-tablets-filters
Jun 9, 2026
Merged

Add filter flags to branch list-tablets#1272
nickvanw merged 1 commit into
mainfrom
add-list-tablets-filters

Conversation

@nickvanw

@nickvanw nickvanw commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

pscale branch list-tablets returned every tablet on a branch with no way to filter. On large, multi-keyspace branches, finding the specific tablet alias you need (e.g. for a throttlerconfig change) meant parsing the full output by hand.

Changes

Four optional flags on branch list-tablets:

  • --keyspace — only list tablets in this keyspace.
  • --shard — only list tablets in this shard (requires --keyspace, matching vitess semantics).
  • --tablet-type — only list tablets of this type (e.g. primary, replica, rdonly).
  • --tablet-alias — only list the tablet(s) with these aliases (comma-separated / repeatable). When set, the other filters are ignored.

With no flags the behavior is unchanged. Validation of the filter combinations (e.g. shard without keyspace, unknown tablet type) is handled server-side and surfaced via the normal error path. Bumps planetscale-go to v0.168.0 for the new ListBranchTabletsRequest filter fields.

Rendered help:

Usage:
  pscale branch vtctld list-tablets <database> <branch> [flags]

Flags:
  -h, --help                   help for list-tablets
      --keyspace string        Only list tablets in this keyspace
      --shard string           Only list tablets in this shard (requires --keyspace)
      --tablet-alias strings   Only list the tablet(s) with these aliases, e.g. zone1-0000000100 (comma-separated; overrides the other filters)
      --tablet-type string     Only list tablets of this type (e.g. primary, replica, rdonly)

Testing

Added list_tablets_test.go: one case asserting an unfiltered call sends empty filters, and one asserting all four flags (including comma-separated --tablet-alias) are forwarded to the SDK request. go build, go vet, gofmt, and the vtctld package tests pass locally; verified the --help output renders the flags as shown above.

`pscale branch list-tablets` returned every tablet on a branch, so
finding a specific tablet alias (e.g. for a throttler config change) on
large, multi-keyspace branches meant parsing the full output by hand.

Add the filters that vtctldclient GetTablets supports, now that the API
and SDK pass them through (planetscale/issues#1955):

- --keyspace, --shard (requires --keyspace), --tablet-type
- --tablet-alias (comma-separated/repeatable; overrides the other
  filters)

Bumps planetscale-go to v0.168.0 for the new ListBranchTabletsRequest
filter fields.
@nickvanw nickvanw requested a review from a team as a code owner June 9, 2026 15:28
@nickvanw nickvanw merged commit 70c8ccc into main Jun 9, 2026
4 checks passed
@nickvanw nickvanw deleted the add-list-tablets-filters branch June 9, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants